home *** CD-ROM | disk | FTP | other *** search
/ Holt Researcher: American History / Holt Researcher: American History.iso / pc / modules / dbpictxt.dxr / 00002_Init Layout Screen.ls < prev    next >
Encoding:
Text File  |  2000-01-27  |  4.8 KB  |  135 lines

  1. global gDBPicttextVarList
  2.  
  3. on InitLayOut
  4.   MyObj = getaProp(gDBPicttextVarList, GetObjProp())
  5.   SetSaveObj(MyObj)
  6.   ShowTitle()
  7.   EnableScroll = ShowPictandText()
  8.   InitScrollLoc()
  9.   InitButtons(EnableScroll)
  10.   updateStage()
  11.   SetScrollHandler()
  12.   InitRollOverText(MyObj)
  13. end
  14.  
  15. on ShowTitle
  16.   MyObj = getaProp(gDBPicttextVarList, GetObjProp())
  17.   SpriteList = GetSpriteList(MyObj)
  18.   TitleSprite = getaProp(SpriteList, #title)
  19.   xMember = member("title f")
  20.   puppetSprite(TitleSprite, 1)
  21.   set the textHeight of member xMember to 14
  22.   set the member of sprite TitleSprite to xMember
  23.   xLoc = point(20, 5)
  24.   if the machineType = 256 then
  25.     set the loc of sprite TitleSprite to xLoc + point(0, -1)
  26.   else
  27.     set the loc of sprite TitleSprite to xLoc
  28.   end if
  29. end
  30.  
  31. on ShowPictandText
  32.   MyObj = getaProp(gDBPicttextVarList, GetObjProp())
  33.   xMemberNum = GetTextMemberNum(MyObj)
  34.   PictMemberNum = GetArtMember(MyObj)
  35.   SpriteList = GetSpriteList(MyObj)
  36.   SetPuppetState(SpriteList, #n, 1)
  37.   PictSp = getaProp(SpriteList, #Art)
  38.   set the member of sprite PictSp to PictMemberNum
  39.   PictRect = GetPictRect(MyObj)
  40.   set the rect of sprite PictSp to PictRect
  41.   return CalcTextSize(SpriteList, xMemberNum, PictRect)
  42. end
  43.  
  44. on CalcTextSize SpriteList, xMemberNum, PictRect
  45.   MyObj = getaProp(gDBPicttextVarList, GetObjProp())
  46.   TextSprite = getaProp(SpriteList, #text)
  47.   NArrowSp = getaProp(SpriteList, #NArrow)
  48.   MinRect = GetTextRect(MyObj, 1)
  49.   CharMap(member(xMemberNum))
  50.   if the machineType = 256 then
  51.     PictRect = PictRect + rect(0, -1, 0, -1)
  52.     MinRect = MinRect + rect(0, -1, 0, -1)
  53.     set the textHeight of member xMemberNum to 14
  54.   end if
  55.   l = getAt(PictRect, 3) + 15
  56.   t = getAt(PictRect, 2)
  57.   R = getAt(MinRect, 3) - the width of sprite NArrowSp - 5
  58.   b = getAt(MinRect, 4)
  59.   TextSprite = getaProp(SpriteList, #text)
  60.   EnableScroll = 0
  61.   member(xMemberNum).scrollTop = 0
  62.   member(xMemberNum).rect = rect(l, t, R, b)
  63.   if member(xMemberNum).height > (GetRectHeight(rect(l, t, R, b)) + 2) then
  64.     EnableScroll = 1
  65.   end if
  66.   set the member of sprite TextSprite to member(xMemberNum)
  67.   set the loc of sprite TextSprite to point(l, t)
  68.   return EnableScroll
  69. end
  70.  
  71. on CharMap xMember
  72.   if the machineType = 256 then
  73.     if count(the windowList) > 0 then
  74.       FieldFindandReplace(xMember, numToChar(147), QUOTE)
  75.       FieldFindandReplace(xMember, numToChar(148), QUOTE)
  76.       FieldFindandReplace(xMember, numToChar(145), "'")
  77.       FieldFindandReplace(xMember, numToChar(146), "'")
  78.     end if
  79.   end if
  80. end
  81.  
  82. on FieldFindandReplace xMember, FindText, ReplaceText
  83.   xText = member(xMember).text
  84.   PositionList = []
  85.   start = the ticks
  86.   repeat while xText contains FindText
  87.     Pos = offset(FindText, xText)
  88.     append(PositionList, Pos)
  89.     put " " into char Pos of xText
  90.   end repeat
  91.   start = the ticks
  92.   repeat with xItem in PositionList
  93.     put ReplaceText into char xItem of field xMember
  94.   end repeat
  95. end
  96.  
  97. on InitScrollLoc
  98.   MyObj = getaProp(gDBPicttextVarList, GetObjProp())
  99.   ButtonList = GetButtonList(MyObj)
  100.   InnerRect = GetInsideRect(the rect of sprite 2, 2)
  101.   xRect = GetTextRect(MyObj, 1)
  102.   SpriteList = GetSpriteList(MyObj)
  103.   TargMember = GetTextMemberNum(MyObj)
  104.   BedSp = getaProp(SpriteList, #VBed)
  105.   NArrowSp = getaProp(SpriteList, #NArrow)
  106.   SArrowSp = getaProp(SpriteList, #SArrow)
  107.   ThumbSp = getaProp(SpriteList, #VThumb)
  108.   sL = getAt(InnerRect, 3) - the width of sprite NArrowSp
  109.   sT = getAt(xRect, 2)
  110.   sR = getAt(InnerRect, 3)
  111.   sB = getAt(InnerRect, 4)
  112.   set the rect of sprite BedSp to rect(sL, sT, sR, sB)
  113.   set the rect of sprite NArrowSp to rect(sL, sT, sR, sT + the height of sprite NArrowSp)
  114.   set the rect of sprite SArrowSp to rect(sL, sB - the height of sprite SArrowSp, sR, sB)
  115.   ThumbXLoc = sL + (the width of sprite NArrowSp / 2)
  116.   ThumbMin = sT + the height of sprite NArrowSp + (the height of sprite ThumbSp / 2) - 2
  117.   ThumbMax = sB - the height of sprite SArrowSp - (the height of sprite ThumbSp / 2)
  118.   set the loc of sprite ThumbSp to point(ThumbXLoc, ThumbMin)
  119.   MinRect = GetTextRect(MyObj, 1)
  120.   numLines = member(TargMember).lineCount
  121.   numVisLines = GetRectHeight(MinRect) / the textHeight of member TargMember
  122.   numSettings = numLines - numVisLines + 1
  123.   addProp(ButtonList, ThumbSp, new(script("scroll thumb sub"), "v scroll", "global", ThumbSp, ThumbXLoc, ThumbMin, ThumbMax, 1, numSettings, 1, numSettings, 0, 0, #downOrRight))
  124.   Slider = getaProp(ButtonList, ThumbSp)
  125.   addProp(ButtonList, BedSp, new(script("scroll bed sub"), "v scroll", "global", BedSp, RectToLoc(rect(sL, sT, sR, sB)), Slider, 15))
  126.   addProp(ButtonList, NArrowSp, new(script("scroll Button"), "scrollup", "global", NArrowSp, the loc of sprite NArrowSp, Slider, 0))
  127.   addProp(ButtonList, SArrowSp, new(script("scroll Button"), "scrolldown", "global", SArrowSp, the loc of sprite SArrowSp, Slider, 1))
  128.   SetButtonList(MyObj, ButtonList)
  129. end
  130.  
  131. on SetScrollHandler
  132.   MyObj = getaProp(gDBPicttextVarList, GetObjProp())
  133.   SetScrollProps(MyObj)
  134. end
  135.